const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    cityItem: {
      type: Object,
      value: null
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    urlStr: [],
    nowIndex: 0, //对应索引，
  },
  attached() {},

  /**
   * 组件的方法列表
   */
  methods: {
    tempData(k) {
      // 截取 
      // console.log('截取=====',k.split("?")[1]);
      this.textUuid(k.split("?")[1])
    },
    textUuid(k) {
      // 使用正则表达
      let match = /((uuid)=([\w]+)).((&rankType)=([\w]+))/g;
      let tempMatch = match.exec(k)
      // console.log(tempMatch);
      this.setData({
        urlStr: tempMatch
      })
    },
    arrowSwitch(k) {
      // console.log('-----',k)
      switch (k) {
        case "24小时热销榜":
          this.setData({
            nowIndex: 1
          })
          break;
        case "完结榜·超人气爆款小说":
          this.setData({
            nowIndex: 4
          })
          break;
        case "最热新书榜":
          this.setData({
            nowIndex: 2
          })
          break;
        default:
          this.setData({
            nowIndex: 0
          })
          break;
      }
    },
    // 跳转
    getNav(e) {

      // 当前列表数据 
      let tempList = e.currentTarget.dataset.cydata
      console.log('----跳转', tempList);
      this.tempData(tempList.more.url)
      this.arrowSwitch(tempList.name)

      console.log(this.data.urlStr[6])
      console.log(this.data.nowIndex)
      wx.navigateTo({
        url: `/pages/bookRank/bookRank?rankType=${this.data.urlStr[6]}&uuid=${this.data.urlStr[3]}&nowIndex=${this.data.nowIndex}`,
      })
      // url="/pages/bookRank/bookRank?rankType={{urlStr[6]}}&uuid={{urlStr[3]}}&nowIndex={{nowIndex}}"
    }
  }
})